﻿using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using NewsInfo; 
public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        tbxNewsDate.Text = System.DateTime.Now.ToString();

        GridView1.DataSource = NewsInfoControl.GetList(n=>n.NewsID <30);
        GridView1.DataBind();
    }
    protected void btnInsert_Click(object sender, EventArgs e)
    {
        NewsInfo.NewsInfo hhh = new NewsInfo.NewsInfo();
        hhh.NewsTitle = tbxNewsTitle.Text;
        hhh.NewsData = tbxNewsData.Text;
        hhh.NewsImageUrl = tbxNewsimg.Text;
        hhh.NewsDate = Convert.ToDateTime(tbxNewsDate.Text);
        hhh.NewsCategory = (NewsCatgory.NewsCatgoryType)Enum.Parse(typeof(NewsCatgory.NewsCatgoryType), rblType.SelectedItem.Value, true);

        NewsInfoControl.Insert(hhh);
        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "提示", "alert('添加成功');location.href=location.href", true);
    }
    protected void btnedit_Click(object sender, EventArgs e)
    {
        Response.Redirect("edit.aspx");
    }
}
